package q10.unittests;

import junit.framework.TestCase;
import q10.Functii.FunctiiElementare.*;
import q10.Arbori.*;

public class PutereTest extends TestCase {

	Nod n;
	Nod nec1=new Necunoscuta();
	Nod nec2=new Necunoscuta();
	
	protected void setUp() throws Exception {
		n=new Putere();
		n.setfDrept(nec1);
		n.setfStang(nec2);
	}

	protected void tearDown() throws Exception {
		n=null;
	}

	public void testCalcul() {
		double rez=Math.pow(this.n.getfDrept().calcul(),this.n.getfStang().calcul());
		assertEquals(rez,this.n.calcul());
	}

	public void testDerivare() {
		String rez=this.n.getfDrept().derivare()+"^"+this.n.getfStang().derivare()+"*ln("+this.n.getfDrept()+")";
		assertEquals(rez,this.n.derivare());
	}

	public void testCalculDerivata() {
		double rez=Math.pow(this.n.getfDrept().calculDerivata(), this.n.getfStang().calculDerivata())*Math.log(this.n.getfDrept().calcul());
		assertEquals(rez,this.n.calculDerivata());
	}

	public void testToString() {
		String rez=this.n.getfDrept()+"^"+this.n.getfStang();
		assertEquals(rez,this.n.toString());
	}

	public void testConcatTermeni() {
		String rez=this.n.getfDrept()+"^"+this.n.getfStang();
		assertEquals(rez,this.n.toString());
	}

}
